Type.registerNamespace('ModWatch');

ModWatch.ModAlertBehaviorBase = function(element) {
	ModWatch.ModAlertBehaviorBase.initializeBase(this, [element]);

    this._modGroup = '';
    this._alertControl = '';
    this._notifyModMessage = '';
}

ModWatch.ModAlertBehaviorBase.prototype = {

	get_modGroup : function()
	{
		return this._modGroup;
	},
	
	set_modGroup : function(value)
	{
		if (!value || value == null)
			this._modGroup = '';
		else
			this._modGroup = value;
	},

	get_alertControl : function()
	{
		return this._alertControl;
	},

	set_alertControl : function(value)
	{
		if (!value || value == null)
			this._alertControl = null;
		else
			this._alertControl = value;
	},

	get_notifyModMessage : function()
	{
		return this._notifyModMessage;
	},

	set_notifyModMessage : function(value)
	{
		if (!value || value == null)
			this._notifyModMessage = '';
		else
			this._notifyModMessage = value;
	},

	isChangeDetected : function()
	{
		return ModWatch.ModManagerInstance.isChangeDetected(this._modGroup);
	},

	verifyChanges : function()
	{
		if (this.isChangeDetected())
		{
			if (this.get_alertControl() && typeof this.get_alertControl().showAlert == 'function')
			{
				var args = new ModWatch.AlertEventArgs();
				this.get_alertControl().showAlert(this, args);
				if (args.get_cancel() == true)
					return false;
			}
			else
			{
				return confirm(this.get_notifyModMessage());
			}
		}

		return true;
	}

}

ModWatch.ModAlertBehaviorBase.registerClass('ModWatch.ModAlertBehaviorBase', Sys.UI.Behavior, ModWatch.IModWatcher);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
